class code1 {
    public String longestCommonPrefix(String[] strs) {
        StringBuffer ret = new StringBuffer();

        for(int i=0;i<strs[0].length();i++) {
            char ch = strs[0].charAt(i);
            for(int j=1;j<strs.length;j++) {
                if(i>=strs[j].length() || ch != strs[j].charAt(i)) {
                    return ret.toString();
                }
            }
            ret.append(ch);
        }
        return ret.toString();
    }
}